package com.assessment.servermanager.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.assessment.servermanager.commen.entity.PageQuery;
import com.assessment.servermanager.commen.page.TableDataInfo;
import com.assessment.servermanager.commen.utils.StringUtils;
import com.assessment.servermanager.entity.TbExam;
import com.assessment.servermanager.entity.bo.TbExamBo;
import com.assessment.servermanager.entity.vo.TbExamVo;
import com.assessment.servermanager.mapper.TbExamMapper;
import com.assessment.servermanager.service.ITbExamService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TbExamServiceImpl implements ITbExamService {
    @Autowired
    private TbExamMapper tbExamMapper;

    @Override
    public TbExam selectTbExamById(Long id) {
        return tbExamMapper.selectById(id);
    }

    @Override
    public TableDataInfo<TbExamVo> selectTbExamList(TbExamBo tbExamBo, PageQuery pageQuery) {
        QueryWrapper<TbExam> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotEmpty(tbExamBo.getExamname()),"exam.exam_name",tbExamBo.getExamname());
        queryWrapper.eq(ObjectUtil.isNotNull(tbExamBo.getEId() != null),"exam.e_id",tbExamBo.getEId());
        queryWrapper.eq(ObjectUtil.isNotNull(tbExamBo.getDId() !=null),"exam.d_id",tbExamBo.getDId());
        queryWrapper.eq(ObjectUtil.isNotNull(tbExamBo.getState() != null),"exam.state",tbExamBo.getState());
        queryWrapper.between(ObjectUtil.isNotNull(tbExamBo.getCreatedTimeStart())&ObjectUtil.isNotNull(tbExamBo.getCreatedTimeEnd()),"emp.createTime",tbExamBo.getCreatedTimeStart(),tbExamBo.getCreatedTimeEnd());
        queryWrapper.eq("exam.delFlag",0);
        Page<TbExamVo> page = tbExamMapper.selectExamListPage(pageQuery.build(),queryWrapper);
        return TableDataInfo.build(page);
    }

    @Override
    public int insertTbExam(TbExam tbExam) {
        return 0;
    }

    @Override
    public int updateTbExam(TbExam tbExam) {
        return 0;
    }

    @Override
    public int deleteTbExamByIds(Long[] ids) {
        return 0;
    }

    @Override
    public int deleteTbExamById(Long id) {
        return 0;
    }
}
